package com.dingding.order.core.common.impl;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.common.core.base.dao.impl.BaseDaoImpl;
import com.dingding.common.core.beans.UserTaxiOrdert;
import com.dingding.common.core.util.ToolUtil;
import com.dingding.order.core.common.IUserTaxiOrderDao;

/**
 * @Description:用户出租车订单dao
 * @author fengshuonan
 * @date 2016年7月6日 下午6:01:02
 * @version 叮叮搭车
 * @since 2.3.0
 */
@Component("userTaxiOrderDao")
public class UserTaxiOrderDaoImpl extends BaseDaoImpl<UserTaxiOrdert> implements IUserTaxiOrderDao {

	private Logger log = Logger.getLogger(this.getClass());

	/**
	 * @Description:获取出租车订单状态
	 * @param orderId 订单id
	 * @author fengshuonan
	 * @return Integer 订单状态   1：待抢单  2：服务中 3：待支付 4：已完成 5：已取消
	 * @since 2.3.0
	 */
	@Override
	@Transactional(readOnly = true)
	public Integer getUserTaxiOrderStatus(String orderId) {
		
		if(ToolUtil.isBlank(orderId)){
			log.error("所查订单id为空！UserOrderDaoImpl:getUserOrderStatus()");
			return null;
		}
		
		try {
			UserTaxiOrdert userordert = super.getById(orderId);
			if(userordert != null){
				return userordert.getOrderStatus();
			}
		} catch (Exception e) {
			log.error("查询订单状态出错！UserOrderDaoImpl:getUserOrderStatus()",e);
		}
		
		return null;
	}

	
}
